package com.igoal.entity;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class UserCompanyPk implements Serializable{
	private static final long serialVersionUID = -5211590512261719154L;
	
	private User user;
	private Company company;
	@ManyToOne
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	@ManyToOne
	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public UserCompanyPk() {
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof UserCompanyPk))
			return false;
		UserCompanyPk castOther = (UserCompanyPk) other;

		return (this.user.getId() == castOther.user.getId())
				&& (this.company.getId() == castOther.company.getId());
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result + (int) this.user.getId().intValue();
		result = 37 * result + (int) this.company.getId().intValue();
		return result;
	}
}
